# coding=utf-8
# 全世界最帅的帅哥
from flask import Flask
from ysgg1_club_comment.config.app_config import ClubConfig
from flask_migrate import Migrate
from ysgg1_club_comment.utils.auth_logging import create_logger
from ysgg1_club_comment.utils.register_server import register_server


def create_app():
    app = Flask(__name__)
    app.config.from_object(ClubConfig)

    app.logger = create_logger(app)

    from ysgg1_club_comment.modules import db
    db.init_app(app)
    # 初始化Migrate  初始化 flask db init  flask db migrate flask db upgrade
    # 执行以上的命令，需要默认的Flask项目入口文件 省得麻烦就把入口文件名设置成app.py 或者wsgi.py
    # 如果实在不喜欢这俩名字
    # $env:FLASK_APP = "ysgg1_club_subject/minio_client.py:app"
    # powershell echo FLASK_APP = "你的入口文件名"  linux export FLASK_APP = "你的入口文件名"
    Migrate(app, db)

    # register_server()

    return app
